apiVersion: v1
kind: Service
metadata:
    name: tomcat-svc
    namespace: spark-cluster
spec:
    type: NodePort
    ports:
    - port: 8080
      targetPort: 8080
      name: tomcat-web
      nodePort: 30080
    - port: 22
      targetPort: 22
      name: tomcat-ssh
      nodePort: 30022
    selector:
        web: tomcat


---
apiVersion: v1
kind: ReplicationController
metadata:
    name: tomcat-rc
    namespace: spark-cluster
spec:
    replicas: 1
    template:
        metadata:
            labels:
                web: tomcat
        spec:
            containers:
            - image: index.tenxcloud.com/zhangshun/tomcat:7.0.72
              name: tomcat
              lifecycle:
                postStart:
                  exec:
                    command: ["ln","-s","/gluster/tomcat/cps-rest.war", "/tomcat/webapps/rta.war"]
              env:
                - name: RTA_CONFIG
                  value: /gluster/localconfig.conf
              volumeMounts:
              - mountPath: /gluster
                name: glusterfsvol
              ports:
              - containerPort: 8080
                name: tomcat-web
              - containerPort: 22
                name: tomcat-ssh

            volumes:
            - name: glusterfsvol
              glusterfs:
                  endpoints: glusterfs-cluster
                  path: {{ gluster_rta_tomcat_volname }}
                  readOnly: false
